package cn.gok.homework;
/*
一 定义Worker类，包含String name，String job（岗位），int salary(工资）;
  a 属性私有，getset公开+全属性构造+toString
  b 增加方法
                         //工作了months个月，返回总的工资
                         public  int  doJob(int months){
                           sout(“xxx工作了xx个月，获得xxx工资");
                           return 总工资；
                        }
  c 在main中创建1个Worker对象，调用doJob方法。


 */
class Worker{
    private String name;
    private String job;
    private int salary;

    @Override
    public String toString() {
        return "Worker{" +
                "name='" + name + '\'' +
                ", job='" + job + '\'' +
                ", salary=" + salary +
                '}';
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getJob() {
        return job;
    }

    public void setJob(String job) {
        this.job = job;
    }

    public int getSalary() {
        return salary;
    }

    public void setSalary(int salary) {
        this.salary = salary;
    }

    public Worker(String name, String job, int salary) {
        this.name = name;
        this.job = job;
        this.salary = salary;
    }
    public  int  doJob(int months){
//        sout(“xxx工作了xx个月，获得xxx工资");
        System.out.println(name+"工作了"+months+"个月，获得"+salary*months+"工资");
        return salary*months;
    }
}
/*

二
定义SuperWorker类，派生于Worker类，增加 float bonus成员变量//奖金系数  ,范围在  【0,1】之间
重写父类的doJob方法，  返回:总工资=普通工人总工资*(1+奖金系数)

同时重载doJob方法增加入参addtionalHours(加班总工时），即
   public  int  doJob(int months,int addtionalHours){
         //返回不带加班时间的doJob返回值 +  bonus*salary*addtionalHours/100
   }
在main中创建1个SuperWorker对象，调用两个doJob方法
 */
class SuperWorker extends Worker{
    private float bonus;

    public SuperWorker(String name, String job, int salary, float bonus) {
        super(name, job, salary);
        this.bonus = bonus;
    }


    @Override
    public int doJob(int months) {
        System.out.println(getName()+"工作了"+months+"个月,获得"+getSalary()*months*(1+bonus)+"工资");
        return (int) (getSalary()*months*(1+bonus));
    }
    public int doJob(int months,int addtionalHour) {
        int sum= (int) (getSalary()*months*(1+bonus)+bonus*getSalary()*addtionalHour/100);
        System.out.println(getName()+"工作了"+months+"个月,加班总工时为"+addtionalHour+",获得"+sum+"工资");
        return sum;
    }
}
public class homework {
    public static void main(String[] args) {
        Worker worker=new Worker("小付","打工",1000);
        System.out.println(worker.doJob(2));
        SuperWorker superWorker=new SuperWorker("李四","医生",5000,0.5f);
        superWorker.doJob(3);
        superWorker.doJob(3, 500);
    }
}
